#include "msg_queue_peer.h"
//该程序的功能是向指定的消息队列发送消息，消息的类型为1，消息的内容为key和value，key和value的值分别为201和1，每隔3秒发送一次。然后在主函数中调用mes_send_use()函数，该函数会一直循环发送消息，直到程序结束。
struct msgbuf
{
    long mtype;
    int key;
    int value;
};
struct msgbuf send;

int mes_send_use()
{
    while (1)
    {send.key = 201;
        send.value = 1;
        if (send.key /100 == 2)
        {
            printf("ready to sendding modbus\n");
            if (msg_queue_send("modbus", &send, sizeof(send), 0) < 0)
            {
                printf("msg_queue_send error\n");
                return -1;
            }
        }
        else if (send.key /100 == 1)
        {
            printf("ready to sendding stm32\n");
            if (msg_queue_send("stm32", &send, sizeof(send), 0) < 0)
            {
                printf("msg_queue_send error\n");
                return -1;
            }
        }
        else
        {
            printf("key error\n");
            return -1;
        }
        sleep(3);
    }
    return 0;
}
int main(int argc, char *argv[])
{
    send.mtype = 1;
    send.key = 201;
    send.value = 1;
    mes_send_use();
    return 0;
}